"""
@title(TenX腾晓2024年11月考核答题文件)
@warning(请勿修改参数和返回值)
@warning(请认真填写__init__中的数据)
@author(1323230180)
"""
from typing import List, Tuple


class TenXClass:
    def __init__(self):
        self.name = "梁演民"
        self.id = "3124002013"

    @staticmethod
    def question1(n: int) -> list[str]:
        print(n)  # 打印，防止IDE警告
        lst = []


        for i in range(1, n + 1):
            num = ""
            while i > 0:
                num = str(i % 4) + num
                i = i // 4
            lst.append(num)



        return lst

    @staticmethod
    def question2() -> list[tuple[int, int, int]]:
        lst = []
        for a in range(0, 34):
            gold = 100 - a
            items = 100 - 3 * a
            for x in range(0, items + 1):
                y = items - x
                if 5 * x + 3 * y == gold:
                    lst.append((x, y, 3 * a))

        return lst

    @staticmethod
    def question3(equipment: list[str], prop: list[str], material: list[str], items: list[str]) -> dict[str, list[str]]:
        print(equipment, prop, material, items)  # 打印，防止IDE警告
        lst1 = []
        lst2 = []
        lst3 = []
        a = 0
        b = 0
        c = 0
        for i in equipment:
            if i in items:
                a = items.count(i)
                lst1 += [i] * a

        for i in prop:
            if i in items:
                b = items.count(i)
                lst2 += [i] * b

        for i in material:
            if i in items:
                c = items.count(i)
                lst3 += [i] * c

        lst4 = [lst1, lst2, lst3]
        lst5 = ["equipment", "prop", 'material']
        zip1 = zip(lst5, lst4)
        return dict(zip1)


    @staticmethod
    def question4(item_values: dict[str, int], items: list[str]) -> tuple[list[str], int]:
        print(item_values, items)  # 打印，防止IDE警告

        sorted_i_and_v = sorted(item_values.items(), key=lambda item: item[1], reverse=True)  # 按价值排序

        lst1 = []  # 储存物品排序方式
        for i in sorted_i_and_v:
            lst1.append(i[0])

        pattern = {item: index for index, item in enumerate(lst1)}


        sorted_items = sorted(items, key=lambda x: pattern[x])
        three_items = sorted_items[0:3]
        sum = 0
        for i in three_items:
            sum +=item_values[i]

        return tuple([three_items, sum])



    @staticmethod
    def question5(matrix: list[list[int]]) -> list[tuple[int, int]]:
        print(matrix)  # 打印，防止IDE警告
        lst = []

        n = len(matrix)
        for i in range(0, n):
            for j in range(0, n):
                if matrix[i][j] == 0:
                    lst.append((i + 1, j + 1))

        return lst
